package com.sunhy.accountserver.mapper;

import com.sunhy.accountserver.entity.BillEntity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BillToMapper {

    @Insert("INSERT INTO `bill_to`(`id`, `user_id`, `from_user_id`, `to_user_id`, `amount`, `status`, `create_date`, `update_date`) " +
            "VALUES (#{id}, #{userId}, #{fromUserId}, #{toUserId}, #{amount}, #{status}, #{createDate}, #{updateDate}) ")
    int insert(BillEntity billEntity);

    @Select("select `id`, `user_id`, `from_user_id`, `to_user_id`, `amount`, `status`, `create_date`, `update_date` from `bill_to` where `id`=#{id} ")
    BillEntity selectById(@Param("id") Long id);

    @Select("select `id`, `user_id`, `from_user_id`, `to_user_id`, `amount`, `status`, `create_date`, `update_date` from `bill_to` ")
    List<BillEntity> selectAll();

    @Update("UPDATE `bill_to` SET `status`=#{status} WHERE `id`=#{id} ")
    int updateStatusById(Integer status, Long id);

}
